﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp3
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    
    public partial class MainWindow : Window
    {
        string[] a = new string[] { "0", "董航聿", "顿佳麒", "傅晓煜", "韩林峰", "何源", "黄程霖", "黄浩然", "黄积权", "黄诗睿", "黄彦凯", "陈天翔", "赖语墨", "李浚铭", "李炫霖", "刘航宇", "刘嘉盛", "刘明亮", "陆天霖", "覃绍帅", "韦佳昕", "韦嘉政", "韦经尧", "徐晗曦", "杨新宇", "叶帅舟", "钟泽辉", "周宇", "朱雨泽", "白兰清玉", "陈丽西", "陈颖欣", "董思思", "顾馨悦", "黄稚晴", "霍琪琪", "江冉月", "李旭蕾", "刘芷萱", "卢雨娜", "陆佳悦", "莫羽淳", "裴缘", "彭佳欣", "邱欣妍", "区晓澜", "宋依娜", "覃金爱", "覃凌湘", "韦超悦", "韦嘉琦", "韦苏洪", "吴浩源", "杨葳妮", "张佳怡", "周桂宇", "宋海翠", "吴嘉欣", "董静仪", "滕艺萱" };
        public MainWindow()
        {
            InitializeComponent();
            Random ran = new Random();
            int RandKey = ran.Next(1, 59);
            Numa.Text = RandKey.ToString();
            Name.Text = a[RandKey];
        }
        
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Random ran = new Random();
            int RandKey = ran.Next(1, 59);
            for (int i =1; i <= 20; i++)
            {
                ran = new Random();
                RandKey = ran.Next(1, 59);
                Numa.Text = RandKey.ToString();
                Name.Text = a[RandKey];
                Delay(30);
            }

            ran = new Random();
            RandKey = ran.Next(1, 59);
            Numa.Text = RandKey.ToString();
            Name.Text = a[RandKey];
        }

        private void Delay(int Millisecond) //延迟系统时间，但系统又能同时能执行其它任务；
        {
            DateTime current = DateTime.Now;
            while (current.AddMilliseconds(Millisecond) > DateTime.Now)
            {
                System.Windows.Forms.Application.DoEvents();//转让控制权            
            }
            return;
        }
    }
}
